package com.zxm.common.core.domain;

import com.tencentcloudapi.common.Credential;
import com.tencentcloudapi.common.profile.ClientProfile;
import com.tencentcloudapi.common.profile.HttpProfile;
import com.tencentcloudapi.facefusion.v20181201.FacefusionClient;
import com.tencentcloudapi.fmu.v20191213.FmuClient;
import com.tencentcloudapi.ft.v20200304.FtClient;
import com.tencentcloudapi.ocr.v20181119.OcrClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * @Author silence.Z
 * @Date 2022/6/14 13:12
 * @PackageName:com.zxm.common.core.domain
 * @ClassName: OCRFactory
 * @Description: OCR文字识别工厂类
 * @Version 1.0
 */
@Component
public class TxyFactory {
	private static String secretId;
	private static String secretKey;
	private static String ocrendpoint;
	private static String ftendpoint;
	private static String fmuendpoint;

	@Value("${txcloud.secretId}")
	public void initSecretId(String s){
		secretId = s;
	}
	@Value("${txcloud.secretKey}")
	public void initSecretKey(String s){
		secretKey = s;
	}
	@Value("${txcloud.ocrendpoint}")
	public void initOcrEndpoint(String s){
		ocrendpoint = s;
	}
	@Value("${txcloud.ftendpoint}")
	public void initFtEndpoint(String s){
		ftendpoint = s;
	}
	@Value("${txcloud.fmuendpoint}")
	public void initFmuEndpoint(String s){
		fmuendpoint = s;
	}

	public static OcrClient createOcr(){
		Credential cred = new Credential(secretId, secretKey);
		// 实例化一个http选项，可选的，没有特殊需求可以跳过
		HttpProfile httpProfile = new HttpProfile();
		httpProfile.setEndpoint(ocrendpoint);
		// 实例化一个client选项，可选的，没有特殊需求可以跳过
		ClientProfile clientProfile = new ClientProfile();
		clientProfile.setHttpProfile(httpProfile);
		// 实例化要请求产品的client对象,clientProfile是可选的
		return new OcrClient(cred, "ap-beijing", clientProfile);
	}
	public static FtClient createFace(){
		Credential cred = new Credential(secretId, secretKey);
		// 实例化一个http选项，可选的，没有特殊需求可以跳过
		HttpProfile httpProfile = new HttpProfile();
		httpProfile.setEndpoint(ftendpoint);
		// 实例化一个client选项，可选的，没有特殊需求可以跳过
		ClientProfile clientProfile = new ClientProfile();
		clientProfile.setHttpProfile(httpProfile);
		// 实例化要请求产品的client对象,clientProfile是可选的
		return new FtClient(cred, "ap-beijing", clientProfile);
	}
	public static FmuClient createFaceShiZhuang(){
		Credential cred = new Credential(secretId, secretKey);
		// 实例化一个http选项，可选的，没有特殊需求可以跳过
		HttpProfile httpProfile = new HttpProfile();
		httpProfile.setEndpoint(fmuendpoint);
		// 实例化一个client选项，可选的，没有特殊需求可以跳过
		ClientProfile clientProfile = new ClientProfile();
		clientProfile.setHttpProfile(httpProfile);
		// 实例化要请求产品的client对象,clientProfile是可选的
		return new FmuClient(cred, "ap-beijing", clientProfile);
	}
}
